#!/usr/bin/env python
# -*- coding: utf-8 -*-

import OpenGL.GL as gl
import imgui
from imgui.integrations.glfw import GlfwRenderer
import glfw

from glfw_utils import init_glfw_window
from template_win import TemplateWindow

def main():
    window = init_glfw_window()
    imgui.create_context()
    impl = GlfwRenderer(window)
    
    template_window = TemplateWindow()
    print(f"imgui version={imgui.VERSION}")

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        template_window.render(imgui)

        # Render frame
        gl.glClearColor(1.0, 1.0, 1.0, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        imgui.render()
        impl.render(imgui.get_draw_data())
        glfw.swap_buffers(window)

    impl.shutdown()
    glfw.terminate()

if __name__ == "__main__":
    main()